<!--
 * @Author: zhangmengqiong
 * @Date: 2021-05-12 14:18:00
 * @LastEditors: zhangmengqiong
 * @LastEditTime: 2021-05-12 14:56:37
-->
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- <script
      type="text/javascript"
      src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=DVPI4kwxgMqXDrTx483rHkB7c3KDRyPp"
    ></script> -->
    <title>异步加载百度地图</title>
    <style type="text/css">
      html {
        width: 100%;
        height: 100%;
      }
      body {
        width: 100%;
        height: 100%;
        margin: 0px;
        padding: 0px;
      }
      #container {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>

  <body>
    <div id="container"></div>
    <script>
      // 异步加载改造
      function init() {
        var map = new BMapGL.Map('container');
        // 创建地图实例
        var point = new BMapGL.Point(116.404, 39.915);
        // 创建点坐标
        map.centerAndZoom(point, 15);
        // 通过滚轮进行放大缩小
        map.enableScrollWheelZoom(true);
        // 初始化地图，设置中心点坐标和地图级别
      }
      // 页面加载完成后，首屏加载完成，进行加载地图
      window.onload = function () {
        // 在首屏加载完成后，创建一个script标签
        var script = document.createElement('script');
        script.src =
          'https://api.map.baidu.com/api?v=1.0&type=webgl&ak=DVPI4kwxgMqXDrTx483rHkB7c3KDRyPp&callback=init';
        document.body.appendChild(script);
      };
    </script>
  </body>
</html>
